package pers.cz.flowcell;

import org.dom4j.Attribute;
import org.dom4j.Element;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: jef-flow-spring-boot-starter
 * @description: 抽象xml小类
 * @author: Cheng Zhi
 * @create: 2023-02-12 17:54
 **/
public abstract class AbstractJefFlowCell implements JefFlowCell {

    private Element element;

    private Map<String, Object> data = new HashMap<String, Object>();

    public AbstractJefFlowCell(Element element) {
        this.element = element;
    }

    private List<Attribute> getAttributes() {
        return element.attributes();
    }

    public Map<String, Object> getData() {
        List<Attribute> attributes = getAttributes();
        for (Attribute attribute : attributes) {
            data.put(attribute.getName(), attribute.getValue());
        }

        return data;
    }
}
